package jn.chen.utils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;

/**
 * @className: DoubleColorBallGenerator
 * @author: chenLin
 * @version: 1.0.0
 * @description:
 * @date: 24/2/27 027 16:28
 */
public class DoubleColorBallGenerator {

    public static void main(String[] args) {
        for (int i = 0; i < 5; i++) {
            List<Integer> redBalls = generateRedBalls();
            int blueBall = generateBlueBall();
            System.out.print("红色球: ");
            for (int j = 0; j < redBalls.size(); j++) {
                System.out.print(redBalls.get(j) + " ");
            }
            System.out.println("蓝色球: " + blueBall);
        }
    }

    public static List<Integer> generateRedBalls() {
        List<Integer> redBalls = new ArrayList<>();
        Random random = new Random();
        while (redBalls.size() < 6) {
            int redBall = random.nextInt(33) + 1;
            if (!redBalls.contains(redBall)) {
                redBalls.add(redBall);
            }
        }
        Collections.sort(redBalls);
        return redBalls;
    }

    public static int generateBlueBall() {
        Random random = new Random();
        return random.nextInt(16) + 1;
    }

}


